﻿using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class _Default : System.Web.UI.Page
{
	protected void Page_Load(object sender, EventArgs e)
	{
	}

	protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
	{
		if (GridView1.SelectedRow.RowType == DataControlRowType.DataRow)
		{
			TableCell cellName = GridView1.SelectedRow.Cells[2];	// Name column 
			txtName.Text = cellName.Text;
		}
	}

	protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
	{
		if (e.Row.RowType == DataControlRowType.DataRow)
		{
			TableCell cellProductNumber = e.Row.Cells[3];	// ProductNumber column
            try
            {

                if (cellProductNumber.Text.Substring(0, 2) == "CA")
                {
                    cellProductNumber.ForeColor = System.Drawing.Color.Green;
                }

                TableCell cellMakeFlag = e.Row.Cells[4];		// MakeFlag column
                CheckBox cb = (CheckBox)cellMakeFlag.Controls[0];
                if (cb.Checked)
                {
                    e.Row.Cells[2].ForeColor = System.Drawing.Color.Red;
                }
            }
            catch (Exception)
            {
                
            }
		}
	}
}
